
/**
 * created on 2012-03-21
 * @author  qiujz
 * @version 1.0
 *
 * Copyright (c)  Founder Software (Suzhou) Co., Ltd.  2012
 *  All rights reserved.
 *
 * 
 * ================================================================
 * Change Revision
 * ---------------------------------------------------------------
 *    DATE                BY                   COMMENT
 * ---------------------------------------------------------------
 * 2012-03-21         qiujz                Create class
 * 
 *
 * ================================================================
 */
package com.founder.bm.controller
{
	import com.founder.bm.common.CommonUtils;
	import com.founder.bm.entity.LoginUserQueryParameter;
	import com.founder.bm.model.LoginUserModel;
	import com.founder.framework.base.BaseController;
	import com.founder.framework.base.BaseModel;
	import com.founder.framework.interfaces.IControllerable;
	
	import mx.collections.ArrayCollection;
	import mx.core.FlexGlobals;
	import mx.rpc.AsyncResponder;
	import mx.rpc.AsyncToken;
	import mx.rpc.events.FaultEvent;
	import mx.rpc.events.ResultEvent;
	import mx.rpc.remoting.RemoteObject;
	
	/**
	 * 页面控制器对象
	 * @author qiujz
	 */
	public class LoginUserController extends BaseController implements IControllerable
	{
		/**
		 * 构造函数
		 * @param model
		 */
		public function LoginUserController(model:LoginUserModel)
		{
			super(model);

			_service=new RemoteObject();
			_service.destination="bm.loginUserService";
			_service.endpoint=CommonUtils.getServer(CommonUtils.BM);
			_service.showBusyCursor=true;
		}

		/**
		 * 获取页面模型对象
		 * @return 模型对象 
		 */
		public function get model():LoginUserModel
		{
			return _model as LoginUserModel;
		}

	
		/**
		 * 取得远程对象查询实体的方法
		 * @return 远程对象查询实体的接口方法
		 */
		public function get getEntityOperation():Object
		{
			return _service.getLoginUserByPrimaryKey;
		}

		/**
		 * 取得远程对象检索实体的方法
		 * @return 远程对象检索实体的接口方法
		 */
		public function get searchOperation():Object
		{
			return _service.searchLoginUserList;
		}

		/**
		 * 取得远程对象新增实体的方法
		 * @return 远程对象新增实体的接口方法
		 */
		public function get insertOperation():Object
		{
			return _service.insertLoginUser;
		}

		/**
		 * 取得远程对象修改实体的方法
		 * @return 远程对象修改实体的接口方法
		 */
		public function get modifyOperation():Object
		{
			return _service.updateLoginUser;
		}

		/**
		 * 取得远程对象删除实体的方法
		 * @return 远程对象删除实体的接口方法
		 */
		public function get deleteOperation():Object
		{
			return _service.deleteLoginUser;
		}

		/**
		 * 取得远程对象批量删除实体的方法
		 * @return 远程对象批量删除实体的接口方法
		 */
		public function get deleteBatchOperation():Object
		{
			return _service.deleteLoginUserBatch;
		}
		
		public function doExportData(param:LoginUserQueryParameter):AsyncToken
		{
			var token:AsyncToken=_service.exportData.send(param);
			token.addResponder(new AsyncResponder(exportDataHandler, faultHandler, token));
			return token;
		}
		
		protected function exportDataHandler(event:ResultEvent, token:AsyncToken=null):void
		{
			var file:String=event.result as String;
			if (file != null && file.length > 0)
			{
				var indexOf:int=file.lastIndexOf("\\");
				var filePath:String=file.slice(0, indexOf);
				var fileName:String=file.slice(indexOf + 1, file.length);
				CommonUtils.getServerDowloadPath(CommonUtils.BM, filePath, fileName);
			}
		}
		
		public function doExportDataTXT(param:LoginUserQueryParameter):AsyncToken
		{
			var token:AsyncToken=_service.exportDataTXt.send(param);
			token.addResponder(new AsyncResponder(exportDataHandler, faultHandler, token));
			return token;
		}

	}
}
